{{define "index"}}
<!DOCTYPE html>
<html>
    <head>
        <title>设置定时关机时间</title>
        <style>
            #contioner{
                width: 800px;
                margin: auto;
                
            }
            .t{
                width: 300px;
                height: 30px;
            }
            #ok{
                width: 300px;
                height: 40px;
                
            }
        </style>
         <script>
            function okClick(){
               var dateval= document.getElementById("date").value;
               var timeval =document.getElementById("time").value;
               var zqval=document.getElementById("zq").value;
               var jd={"date":dateval,"time":timeval,"zhouqi":parseInt(zqval)};
               var jsstr=JSON.stringify(jd);
               
               var xhr = new XMLHttpRequest;

                xhr.open('post','/settime');
                // post请求的参数要放在send方法中作为参数的 - 必须的字符串
                // post请求要带参数必须在send之前设置 头信息
                xhr.setRequestHeader('content-type', 'application/json')
                // 数据在传送之前需要进行编码
                xhr.send(jsstr)
                xhr.onreadystatechange = function(){
                    if(xhr.readyState === 4){
                        if(xhr.status>=200 && xhr.status<300){
                            var res = xhr.responseText;
                                res = JSON.parse(res)
                                alert(res.msg)
                        }
                    }
                }

            }
         </script>
    </head>
    <body>
        
        <div id="contioner">
            <p><h1 >定时关机设置</h6></p>
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日期：<input id="date" class="t" type="date" value="{{.Date}}" /></p>
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;时间：<input id="time" class="t" type="time" step="1" value="{{.Time}}" /></p>
            <p>轮询周期：<input id="zq" class="t" type="number"  min="1" value="{{.Zhouqi}}" />(秒)</p>
            <p><button id="ok" onclick="okClick();">确定</button></p>
        </div>

        
    </body>
   
</html>
{{end}}